<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">

<head lang="en">
  <meta charset="UTF-8">
  <title>文章列表</title>
  <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
  <link rel="stylesheet" href="/css/footer.css">
  <link rel="stylesheet" href="/css/blog.css">
  <link rel="stylesheet" href="/css/admin.css">
  <script src="//cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
  <script src="//cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head>

<!--/*@thymesVar id="blogs" type="com.github.pagehelper.PageInfo"*/-->
<!--/*@thymesVar id="blog" type="club.banyuan.blog.bean.Blog"*/-->
<!--/*@thymesVar id="username" type="java.lang.String"*/-->

<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="./list.html">Lorem 的博客</a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li><a href="/">首页</a></li>
        <li><a href="#">最近</a></li>
        <li><a href="#">归档</a></li>
        <li><a href="#">关于</a></li>
      </ul>
      <form class="navbar-form navbar-right">
        <input type="text" class="form-control" placeholder="搜索...">
      </form>
    </div>
  </div>
</nav>

<div class="container">

  <div class="page-header">

    <div class="alert alert-success" th:unless="${#strings.isEmpty(message)}">
<!--    <div class="alert alert-success">-->
      <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
      <strong>Ha!</strong> 注册成功了,开始创建你的博客吧!
    </div>

    <h1 class="blog-title">Lorem 的博客
      <small class="blog-description">Mi nunc congue nunc, ante felis vestibulum bibendum.</small>
    </h1>
  </div>
  <div>
    <a href="/admin/blog/create" class="btn btn-primary blog-post-create-btn">创建新博客</a>
  </div>
  <div class="row">

    <div class="table-responsive blog-post-list">
      <table class="table table-striped blog-post-list-table">
        <thead>
        <tr>
          <th>文章标题</th>
          <th>创建时间</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr class="blog-post" th:each="blog: ${blogs.list}">
          <td class="blog-post-title" th:text="${blog.title}">"${blog.title}"</td>
          <td class="blog-post-create-date" th:text="${#dates.format(blog.createdTime, 'yyyy年MM月dd日')}">"{blog.createdTime}"</td>
          <td>
            <a class="btn btn-primary blog-post-edit-btn" th:href="@{'/admin/blog/' + ${blog.id} + '/edit'}">编辑</a>
            <form class="blog-post-delete-form" th:action="|/admin/blog/${blog.id}|" method="post" onsubmit="return confirm('确定要删除这篇文章吗？');">
              <input type="hidden" name="_method" value="delete">
              <button type="submit" class="btn btn-danger blog-post-delete-btn">删除</button>
            </form>
          </td>
        </tr>
        <tr class="blog-post" th:remove="all">
          <td class="blog-post-title">Vel volutpat dictum sagittis lacus</td>
          <td class="blog-post-create-date">2015年2月3日</td>
          <td>
            <a class="btn btn-primary blog-post-edit-btn" href="#">编辑</a>
            <form class="blog-post-delete-form" action="#" method="post" onsubmit="return confirm('确定要删除这篇文章吗？');">
              <button type="submit" class="btn btn-danger blog-post-delete-btn">删除</button>
            </form>
          </td>
        </tr>
        </tbody>
      </table>
    </div>

    <nav>
      <ul class="pager">

        <li th:if="${blogs.hasPreviousPage}" class="previous"><a th:href="@{'/admin/'+ ${username} + '?page=' + ${blogs.prePage}}"><span aria-hidden="true">&larr;</span> 上一页</a></li>
        <li th:if="${blogs.hasNextPage}" class="next"><a th:href="@{'/admin/'+ ${username} + '?page=' + ${blogs.nextPage}}">下一页 <span aria-hidden="true">&rarr;</span></a></li>

      </ul>
    </nav>

  </div>

</div>

</body>
</html>
